package com.ruiysoft.service.order.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruiysoft.controller.sys.dto.OrderRelationCommissionDto;
import com.ruiysoft.entity.order.OrderRelationCommission;
import com.ruiysoft.entity.sys.SysShopPersonnel;
import com.ruiysoft.mapper.order.OrderRelationCommissionMapper;
import com.ruiysoft.service.order.IOrderRelationCommissionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author huazengguang
 * @since 2019-10-13
 */
@Service
public class OrderRelationCommissionServiceImpl extends ServiceImpl<OrderRelationCommissionMapper, OrderRelationCommission> implements IOrderRelationCommissionService {

    @Autowired
    OrderRelationCommissionMapper orderRelationCommissionMapper;
    @Override
    public Page<SysShopPersonnel> getRelationCommissionList(Integer pageStart, Integer pageSize, Long shopId) {
        Page<OrderRelationCommissionDto> page = new Page<>(pageStart, pageSize);
        List ls= orderRelationCommissionMapper.getRelationCommissionList(page, shopId);
        return page.setRecords(ls);
    }

    @Override
    public Page<OrderRelationCommission> getRelationCommissionByUserId(Integer pageStart, Integer pageSize, Long shopId, Long userId) {
        Page<OrderRelationCommission> page = new Page<>(pageStart, pageSize);
        List ls= orderRelationCommissionMapper.getRelationCommissionByUserId(page, shopId,userId);
        return page.setRecords(ls);
    }
    @Override
    public Page<OrderRelationCommission> getRelationCommissionByBuyerId(Integer pageStart, Integer pageSize, Long shopId, Long userId, Long id) {
        Page<OrderRelationCommission> page = new Page<>(pageStart, pageSize);
        List ls= orderRelationCommissionMapper.getRelationCommissionByBuyerId(page, shopId,userId,id);
        return page.setRecords(ls);
    }
    @Override
    public Page<OrderRelationCommission> getRelationCommissionDisByUserId(Integer pageStart, Integer pageSize, Long shopId, Long userId) {
        Page<OrderRelationCommission> page = new Page<>(pageStart, pageSize);
        List ls= orderRelationCommissionMapper.getRelationCommissionDisByUserId(page, shopId,userId);
        return page.setRecords(ls);
    }

    @Override
    public Page getCurrentDistributionerList(Integer pageStart, Integer pageSize, Long shopId, Long userId) {
        Page<OrderRelationCommissionDto> page = new Page<>(pageStart, pageSize);
        List ls= orderRelationCommissionMapper.getCurrentDistributionerList(page, shopId,userId);
        return page.setRecords(ls);
    }

//    @Override
//    public boolean settleCommissionByIds(Long shopId, List<String> ids) {
//       // return orderRelationCommissionMapper.settleCommissionByIds(ids);
//    }
}
